package org.jtao.gbsubject.service.mapper;

import org.jtao.gbsubject.domain.*;
import org.jtao.gbsubject.service.dto.SubjectClazzDTO;

import org.mapstruct.*;

/**
 * Mapper for the entity SubjectClazz and its DTO SubjectClazzDTO.
 */
@Mapper(componentModel = "spring", uses = {TopSubjectMapper.class})
public interface SubjectClazzMapper extends EntityMapper<SubjectClazzDTO, SubjectClazz> {

    @Mapping(source = "topSubject.id", target = "topSubjectId")
    @Mapping(source = "topSubject.name", target = "topSubjectName")
    SubjectClazzDTO toDto(SubjectClazz subjectClazz);

    @Mapping(source = "topSubjectId", target = "topSubject")
    SubjectClazz toEntity(SubjectClazzDTO subjectClazzDTO);

    default SubjectClazz fromId(Long id) {
        if (id == null) {
            return null;
        }
        SubjectClazz subjectClazz = new SubjectClazz();
        subjectClazz.setId(id);
        return subjectClazz;
    }
}
